package artid.com.arttogoa.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import artid.com.arttogoa.EditFilingQuickSell_Activity;
import artid.com.arttogoa.R;
import artid.com.arttogoa.app.ArtWorkApp;
import artid.com.arttogoa.barcode.Bimp;
import artid.com.arttogoa.parser.FilingQuickSellParser;
import artid.com.arttogoa.util.NetUtils;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * 
 *    
 * 项目名称：ArtworkArtA   
 * 类名称   ：FilingQuickSell_Adapter   
 * 类描述   ：备案一键出售适配器   
 * 创建人   ：耿卫斌   
 * 创建时间：2016-7-14 上午9:53:52   
 *
 */
public class FilingQuickSell_Adapter extends BaseAdapter{
	private Context mContext;
	private List<FilingQuickSellParser> list;

	public FilingQuickSell_Adapter(Context mContext,
			List<FilingQuickSellParser>  list) {
		super();
		this.mContext = mContext;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		View v = convertView;
		if (v == null) {
			holder = new ViewHolder();
			v = LayoutInflater.from(mContext).inflate(R.layout.item_filingquicksell, null);
			holder.img=(ImageView) v.findViewById(R.id.item_filingquicksell_img);
			holder.title=(TextView) v.findViewById(R.id.item_filingquicksell_title);
			holder.time=(TextView) v.findViewById(R.id.item_filingquicksell_time);
			holder.submit=(TextView) v.findViewById(R.id.item_filingquicksell_btn);
			v.setTag(holder);
		} else {
			holder = (ViewHolder) v.getTag();
		}
		ImageLoader.getInstance().displayImage(list.get(position).getImgurl() 
				+ "_"+ NetUtils.dip2px(mContext, 100)+"x"+NetUtils.dip2px(mContext, 100)+".png",
				holder.img);
		holder.title.setText(list.get(position).getTitle());
		holder.time.setText(list.get(position).getFinnshed_time());
		holder.submit.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i=new Intent(mContext,EditFilingQuickSell_Activity.class);
				i.putExtra("goodsType", Bimp.GOODS_PUBLISH);
				i.putExtra("art_id", list.get(position).getArt_id());
				mContext.startActivity(i);
				ArtWorkApp.getInstance().addActivity((Activity)mContext);
			}
		});
		return v;
	}
	class ViewHolder {
		ImageView img;
		TextView title,time,submit;
	}

}
